/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kallsonys.object;

import java.io.Serializable;
import java.math.BigInteger;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Cacheable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author alladiab
 */
@Entity
@Cacheable(false)
@Table(name = "CREDITCARD")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Creditcard.findAll", query = "SELECT c FROM Creditcard c"),
    @NamedQuery(name = "Creditcard.findByCreditcardid", query = "SELECT c FROM Creditcard c WHERE c.creditcardid = :creditcardid"),
    @NamedQuery(name = "Creditcard.findByCreditcardtype", query = "SELECT c FROM Creditcard c WHERE c.creditcardtype = :creditcardtype"),
    @NamedQuery(name = "Creditcard.findByCreditcardnumber", query = "SELECT c FROM Creditcard c WHERE c.creditcardnumber = :creditcardnumber"),
    @NamedQuery(name = "Creditcard.findByCreditcardexpirationmonth", query = "SELECT c FROM Creditcard c WHERE c.creditcardexpirationmonth = :creditcardexpirationmonth"),
    @NamedQuery(name = "Creditcard.findByCreditcardexpirationyear", query = "SELECT c FROM Creditcard c WHERE c.creditcardexpirationyear = :creditcardexpirationyear"),
    @NamedQuery(name = "Creditcard.findByCreditcardverificationnumber", query = "SELECT c FROM Creditcard c WHERE c.creditcardverificationnumber = :creditcardverificationnumber"),
    @NamedQuery(name = "Creditcard.findBySavecreditcardnumber", query = "SELECT c FROM Creditcard c WHERE c.savecreditcardnumber = :savecreditcardnumber"),
    @NamedQuery(name = "Creditcard.findByCustumerId", query = "SELECT c FROM Creditcard c WHERE c.customerid = :customerid")})
public class Creditcard implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @GeneratedValue(generator="CreditCardSeq")
    @SequenceGenerator(name="CreditCardSeq",sequenceName="SEQ_CREDITCARD",initialValue=1, allocationSize=1)
    @Column(name = "CREDITCARDID")
    private Long creditcardid;
    @Basic(optional = false)
    @NotNull
    @Column(name = "CREDITCARDTYPE")
    private BigInteger creditcardtype;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "CREDITCARDNUMBER")
    private String creditcardnumber;
    @Basic(optional = false)
    @NotNull
    @Column(name = "CREDITCARDEXPIRATIONMONTH")
    private BigInteger creditcardexpirationmonth;
    @Basic(optional = false)
    @NotNull
    @Column(name = "CREDITCARDEXPIRATIONYEAR")
    private BigInteger creditcardexpirationyear;
    @Size(max = 3)
    @Column(name = "CREDITCARDVERIFICATIONNUMBER")
    private String creditcardverificationnumber;
    @Basic(optional = false)
    @NotNull
    @Column(name = "SAVECREDITCARDNUMBER")
    private short savecreditcardnumber;
    @JoinColumn(name = "CUSTOMERID", referencedColumnName = "CUSTOMERID")
    @ManyToOne(fetch= FetchType.LAZY,optional = false)
    private Customer customerid;
    @OneToMany(mappedBy = "lastusedcreditcardid", fetch= FetchType.LAZY)
    private List<Customer> customerList;

    public Creditcard() {
    }

    public Creditcard(Long creditcardid) {
        this.creditcardid = creditcardid;
    }

    public Creditcard(Long creditcardid, BigInteger creditcardtype, String creditcardnumber, BigInteger creditcardexpirationmonth, BigInteger creditcardexpirationyear, short savecreditcardnumber) {
        this.creditcardid = creditcardid;
        this.creditcardtype = creditcardtype;
        this.creditcardnumber = creditcardnumber;
        this.creditcardexpirationmonth = creditcardexpirationmonth;
        this.creditcardexpirationyear = creditcardexpirationyear;
        this.savecreditcardnumber = savecreditcardnumber;
    }

    public Long getCreditcardid() {
        return creditcardid;
    }

    public void setCreditcardid(Long creditcardid) {
        this.creditcardid = creditcardid;
    }

    public BigInteger getCreditcardtype() {
        return creditcardtype;
    }

    public void setCreditcardtype(BigInteger creditcardtype) {
        this.creditcardtype = creditcardtype;
    }

    public String getCreditcardnumber() {
        return creditcardnumber;
    }

    public void setCreditcardnumber(String creditcardnumber) {
        this.creditcardnumber = creditcardnumber;
    }

    public BigInteger getCreditcardexpirationmonth() {
        return creditcardexpirationmonth;
    }

    public void setCreditcardexpirationmonth(BigInteger creditcardexpirationmonth) {
        this.creditcardexpirationmonth = creditcardexpirationmonth;
    }

    public BigInteger getCreditcardexpirationyear() {
        return creditcardexpirationyear;
    }

    public void setCreditcardexpirationyear(BigInteger creditcardexpirationyear) {
        this.creditcardexpirationyear = creditcardexpirationyear;
    }

    public String getCreditcardverificationnumber() {
        return creditcardverificationnumber;
    }

    public void setCreditcardverificationnumber(String creditcardverificationnumber) {
        this.creditcardverificationnumber = creditcardverificationnumber;
    }

    public short getSavecreditcardnumber() {
        return savecreditcardnumber;
    }

    public void setSavecreditcardnumber(short savecreditcardnumber) {
        this.savecreditcardnumber = savecreditcardnumber;
    }

    public Customer getCustomerid() {
        return customerid;
    }

    public void setCustomerid(Customer customerid) {
        this.customerid = customerid;
    }

    @XmlTransient
    public List<Customer> getCustomerList() {
        return customerList;
    }

    public void setCustomerList(List<Customer> customerList) {
        this.customerList = customerList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (creditcardid != null ? creditcardid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Creditcard)) {
            return false;
        }
        Creditcard other = (Creditcard) object;
        if ((this.creditcardid == null && other.creditcardid != null) || (this.creditcardid != null && !this.creditcardid.equals(other.creditcardid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return creditcardnumber;
    }
    
}
